/**
* Created by Administrator on 2025/5/7.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "PC/PC.h"
#include "MTD/MTD.h"
#include "CFAR/CFAR.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "Spot/Spot.h"
#include "MTI/MTI.h"
#include "Track/Track.h"
#include "MyDeviceWriter/MyDeviceWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=1;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(PC,MyDeviceReader,MyDeviceWriter,MTD,CFAR,Spot,MTI,Track);
    auto pc = new PC();
    auto mtd = new MTD();
    auto cfar = new CFAR();
    auto sopt = new Spot();
    auto mti = new MTI();
    auto track = new Track();

    mtd->addOutput(0,0,cfar,1024);
    pc->addOutput(0,0,mti,1024);
    mti->addOutput(0,0,mtd,1024);
    cfar->addOutput(0,0,sopt,1024);
    sopt->addOutput(0,0,track,1024);

    auto radarlabWriter = new MyDeviceWriter();
    track->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_2 = new MyDeviceWriter();
    track->addDeviceWriter(1,radarlabWriter_2,1024);

    auto radarlabWriter_1 = new MyDeviceWriter();
    sopt->addDeviceWriter(1,radarlabWriter_1,1024);

    auto radarlabWriter_3 = new MyDeviceWriter();
    pc->addDeviceWriter(1,radarlabWriter_3,1024);

    auto radarlabWriter_4 = new MyDeviceWriter();
    cfar->addDeviceWriter(1,radarlabWriter_4,1024);

    auto radarlabWriter_5 = new MyDeviceWriter();
    cfar->addDeviceWriter(2,radarlabWriter_5,1024);

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(pc,0,1024);

    auto radarlabReader_1 = new MyDeviceReader();
    radarlabReader_1->addTaskModule(pc,1,1024);
    REGISTER_INSTANCES(pc,radarlabReader,radarlabReader_1,radarlabWriter_3,mtd,cfar,radarlabWriter_4,radarlabWriter_5,sopt,radarlabWriter_1);
    REGISTER_INSTANCES(mti,track,radarlabWriter,radarlabWriter_2);
}
